home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
oper_sys
/
oasis
/
oasisegs.lha
/
egs
/
mmul.lisp
< prev
next >
Wrap
Lisp/Scheme
|
1992-04-23
|
2KB
|
59 lines
(proclaim '(type fixnum *n*))
(proclaim '(type (array fixnum 2) *a*))
(proclaim '(type (array fixnum 2) *b*))
(proclaim '(type (array fixnum 2) *c*))
(proclaim '(function gen ((array fixnum 2) fixnum) nil))
(defvar *n* 64)
(defvar *a* (make-array (cons *n* (cons *n* nil))
:element-type 'fixnum
:initial-element 0))
(defvar *b* (make-array (cons *n* (cons *n* nil))
:element-type 'fixnum
:initial-element 0))
(defvar *c* (make-array (cons *n* (cons *n* nil))
:element-type 'fixnum
:initial-element 0))
(defun run (m)
(declare (type fixnum m))
(do ((k m (- k 1)))
((zerop k) nil)
(declare (type fixnum k))
(gen *a* *n*)
(gen *b* *n*)
(mmul) ))
(defun mmul ()
(do ((i 0 (+ i 1)))
((= i *n*) nil)
(declare (type fixnum i))
(do ((j 0 (+ j 1)))
((= j *n*) nil)
(declare (type fixnum j))
(do ((k 0 (+ k 1))
(sum 0) )
((= k *n*) (setf (aref *c* i j) sum))
(declare (type fixnum k)
(type fixnum sum) )
(setf sum (+ sum (* (aref *a* i k) (aref *b* k j)))) ))))
(defun gen (mat n)
(declare (type (array fixnum 2) mat)
(type fixnum n) )
(let ((seed 197)
(b 0) )
(declare (type fixnum seed)
(type fixnum b) )
(do ((i 0 (+ i 1)))
((= i n))
(declare (type fixnum i))
(do ((j (+ i 1) (+ j 1)))
((= j n))
(declare (type fixnum j))
(setf seed (rem (+ (* 4757 seed) 1) 32768))
(setf b (+ 1 (rem (truncate (/ seed 16)) 256)))
(setf (aref mat i j) b)
(setf (aref mat j i) b) ))))